import java.util.Arrays;

class Solution {
    public static int[] getAverages(int[] nums, int k) {
        int n=nums.length;
        int[] arr=new int[n];
        Arrays.fill(arr,-1);
        if(2*k+1>n){
            return arr;
        }
        long sum=0;
        for (int i = 0; i < 2*k+1; i++) {
            sum+=nums[i];
        }
        int p=k;
        arr[p]=(int)(sum/(2*k+1));
        p++;
        while(p<=n-k-1){
            sum+=nums[p+k];
            sum-=nums[p-k-1];
            arr[p]=(int)(sum/(2*k+1));
            p++;
        }
        return arr;
    }
}